package com.bootdo.system.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bootdo.system.domain.BizCustomerPayDO;
import com.bootdo.system.service.BizCustomerPayService;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.common.utils.R;

/**
 * 客户支付记录
 * 
 * @author chglee
 * @email 1992lcg@163.com
 * @date 2019-06-25 10:10:26
 */
 
@Controller
@RequestMapping("/system/bizCustomerPay")
public class BizCustomerPayController {
	@Autowired
	private BizCustomerPayService bizCustomerPayService;
	
	@GetMapping()
	@RequiresPermissions("system:bizCustomerPay:bizCustomerPay")
	String BizCustomerPay(){
	    return "system/bizCustomerPay/bizCustomerPay";
	}
	
	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("system:bizCustomerPay:bizCustomerPay")
	public PageUtils list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
		List<BizCustomerPayDO> bizCustomerPayList = bizCustomerPayService.list(query);
		int total = bizCustomerPayService.count(query);
		PageUtils pageUtils = new PageUtils(bizCustomerPayList, total);
		return pageUtils;
	}
	
	@GetMapping("/add")
	@RequiresPermissions("system:bizCustomerPay:add")
	String add(){
	    return "system/bizCustomerPay/add";
	}

	@GetMapping("/edit/{tid}")
	@RequiresPermissions("system:bizCustomerPay:edit")
	String edit(@PathVariable("tid") String tid,Model model){
		BizCustomerPayDO bizCustomerPay = bizCustomerPayService.get(tid);
		model.addAttribute("bizCustomerPay", bizCustomerPay);
	    return "system/bizCustomerPay/edit";
	}
	
	/**
	 * 保存
	 */
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("system:bizCustomerPay:add")
	public R save( BizCustomerPayDO bizCustomerPay){
		if(bizCustomerPayService.save(bizCustomerPay)>0){
			return R.ok();
		}
		return R.error();
	}
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("system:bizCustomerPay:edit")
	public R update( BizCustomerPayDO bizCustomerPay){
		bizCustomerPayService.update(bizCustomerPay);
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/remove")
	@ResponseBody
	@RequiresPermissions("system:bizCustomerPay:remove")
	public R remove( String tid){
		if(bizCustomerPayService.remove(tid)>0){
		return R.ok();
		}
		return R.error();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/batchRemove")
	@ResponseBody
	@RequiresPermissions("system:bizCustomerPay:batchRemove")
	public R remove(@RequestParam("ids[]") String[] tids){
		bizCustomerPayService.batchRemove(tids);
		return R.ok();
	}
	
}
